﻿<cfsilent>
	<cfscript>
		
		depId = event.getArg("DepID");
		tchId = event.getArg("TCHID");
		
		sql = "SELECT a.institute_name
				FROM t_institute a 
				WHERE a.institute_id = :depId ";
		
		queryObj = new query( datasource=application.dnsSlave  );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_ins = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT a.tch_id,a.tch_idcard,
					   a.tch_name,a.tch_sex,
					   b.institute_name,c.tp_series,
					   c.tp_rank,d.edu_background,
					   a.tch_tel,a.institute_id,
					   d.edu_id,c.tp_id,
      		 		   a.tch_type, 
					   a.point_manager,
					   a.paper_manager  
				FROM t_teacher a 
					 INNER JOIN t_institute b ON b.institute_id = a.institute_id 
					 INNER JOIN t_technical_position c ON c.tp_id = a.tp_id 
					 INNER JOIN t_teacher_educational d ON d.edu_id = a.edu_id 
				WHERE a.tch_id = :tchId ";
			
		queryObj = new query( datasource=application.dnsSlave  );
		queryObj.addParam( name="tchId", value=tchId, cfsqltype="cf_sql_varchar" );
		
		rs_teacher = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT a.user_email,a.user_login, role   
				FROM t_user a 
				WHERE a.user_id = :tchId ";
		
		queryObj = new query( datasource=application.dnsSlave  );
		queryObj.addParam( name="tchId", value=tchId, cfsqltype="cf_sql_varchar" );
		
		rs_user = queryObj.execute( sql=sql ).getResult();
	
		sql = "SELECT 
				a.institute_id, a.institute_name
				FROM t_institute a 
				ORDER BY a.classification, a.institute_name ";
				
		queryObj = new query( datasource=application.dnsSlave  );
		
		rs_department = queryObj.execute( sql=sql ).getResult();
		
							
		sql = "SELECT 
					a.tp_id, a.tp_series 
				FROM t_technical_position a  
				WHERE 
					SUBSTR(a.tp_id, 1, 2) IN ('01','06','07','08','13') 
				ORDER BY 
					a.tp_id";
					
		queryObj = new query( datasource=application.dnsSlave  );
		
		rs_technicalPosition = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
					a.edu_id, a.edu_background
				FROM t_teacher_educational a  
				WHERE 
					SUBSTR(a.edu_id, 1, 1) in ('0','1','2','3','4') 
				ORDER BY 
					a.edu_id";	
			
		queryObj = new query( datasource=application.dnsSlave  );
		
		rs_educational = queryObj.execute( sql=sql ).getResult();	
		
		sql = "SELECT 
				a.tch_type, a.tch_type_name
				FROM t_teacher_type a 
				ORDER BY 
					a.tch_type";
					
		queryObj = new query( datasource=application.dnsSlave  );
		
		rs_type = queryObj.execute( sql=sql ).getResult();	
		
		currentTab = event.getArg("TabID", "labWelcome");
		
		passArgs = structNew();
		structInsert( passArgs, "DepID", depId, true );
		
		
		event.setArg("pageTitle", "师资工作量 - 教师档案");
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('instituteTeacher', passArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText"><cfoutput>#rs_ins.institute_name#</cfoutput></span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>教师档案
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="welcome">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labWelcome">class="active"</cfif> id="labWelcome" tabTarget="Welcome">注册信息</span>
						<span <cfif currentTab eq "labModify">class="active"</cfif> id="labModify" tabTarget="Modify">修改教师档案</span>
                              <span <cfif currentTab eq "labPicture">class="active"</cfif> id="labPicture" tabTarget="Picture">照片</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				
				<div id="Welcome" class="tabContent">
				
					<div class="noticeBlock">
						<h3>教职工基础信息</h3>
						<hr/>
					</div>
					
					<table class="UItable withBorder">
						<tr>
							<td>职工号</td>
							<td colspan="3"><span class="number"><cfoutput>#rs_teacher.tch_id#</cfoutput></span></td>
							
							<td style="padding:0;" width="135" height="180" valign="middle" align="center" rowspan="5"><img width="135" height="180" align="middle" src="teacher/profile/<cfoutput>#rs_teacher.tch_id#</cfoutput>.jpg" /></td>
						</tr>
						<tr>
                              	<td>姓名</td>
							<td><cfoutput>#rs_teacher.tch_name#</cfoutput></td>
							<td>性别</td>
							<td><cfif rs_teacher.tch_sex eq "1">男<cfelse>女</cfif></td>
						</tr>
						<tr>
							<td>所在院（部、中心）</td>
							<td colspan="3"><cfoutput>#rs_teacher.institute_name#</cfoutput></td>
						</tr>
						<tr>
							<td>电子邮件</td>
							<td><span class="number"><cfoutput>#rs_user.user_email#</cfoutput></span></td>
							<td>联系电话</td>
							<td><span class="number"><cfoutput>#rs_teacher.tch_tel#</cfoutput></span></td>
						</tr>
                              <tr>
							<td>登录系统用户名</td>
							<td colspan="3"><cfoutput>#rs_user.user_login#</cfoutput></td>
						</tr>
					</table>
					
				</div>
				
				<div id="Modify" class="tabContent">
					
					<div class="noticeBlock">
						<h3>修改您的个人信息</h3>
						<hr/>
					</div>
					
					<form id="formEdit" onSubmit="javascript:return processVerfiyForm('formEdit');" class="formWrapper" method="post" action="<cfoutput>#buildURL('teacherProfileUpdateDo')#</cfoutput>">
						
						<input name="TeacherID" type="hidden" value="<cfoutput>#rs_teacher.tch_id#</cfoutput>" />
						
						<div class="label">
							<span class="req">*</span><b>教师姓名</b>
							<input name="TeacherName" id="TeacherName" type="text" class="typeTextTiny inlinePart" verification="required" maxlength="15" value="<cfoutput>#event.getArg('TeacherName', rs_teacher.tch_name)#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>性别</b>
							<input name="TeacherSex" type="radio" class="typeRadio" value="1" <cfif event.getArg('TeacherSex', rs_teacher.tch_sex) eq "1">checked="checked"</cfif> />男
							<input name="TeacherSex" type="radio" class="typeRadio" value="2" <cfif event.getArg('TeacherSex', rs_teacher.tch_sex) eq "2" >checked="checked"</cfif> />女
						</div>
                              
                              <div class="label">
							<b>学分指导老师</b>
							<input name="pointManager" type="radio" class="typeRadio" value="0" <cfif event.getArg('pointManager', rs_teacher.point_manager) eq "0">checked="checked"</cfif> />否
							<input name="pointManager" type="radio" class="typeRadio" value="1" <cfif event.getArg('pointManager', rs_teacher.point_manager) eq "1" >checked="checked"</cfif> />是
						</div>
                              
                               <div class="label">
							<b>论文指导老师</b>
							<input name="paperManager" type="radio" class="typeRadio" value="0" <cfif event.getArg('paperManager', rs_teacher.paper_manager) eq "0">checked="checked"</cfif> />否
							<input name="paperManager" type="radio" class="typeRadio" value="1" <cfif event.getArg('paperManager', rs_teacher.paper_manager) eq "1" >checked="checked"</cfif> />是
						</div>
                              
						<input name="TeacherIDCard" id="TeacherIDCard" type="hidden" class="typeIDCard inlinePart" maxlength="18" value="<cfoutput>#event.getArg('TeacherIDCard', rs_teacher.tch_idcard)#</cfoutput>" />
                              
                              <input name="InstituteID" id="InstituteID" type="hidden" class="inlinePart" maxlength="18" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />
                               
                               <input name="TypeCode" id="TypeCode" type="hidden" class="inlinePart" maxlength="18" value="<cfoutput>#rs_teacher.tch_type#</cfoutput>" />
						<!---<div class="label">
							<span class="req">*</span><b>身份证号</b>
							<input name="TeacherIDCard" id="TeacherIDCard" type="text" class="typeIDCard inlinePart" maxlength="18" value="<cfoutput>#event.getArg('TeacherIDCard', rs_teacher.tch_idcard)#</cfoutput>" />
							<p class="notice">教师个人证件号码, 该资料会用于统一身份认证后的用户身份确认, 课酬发放以及和其他业务系统的数据交换</p>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>工作部门</b>
							<select name="InstituteID" id="InstituteID" class="inlinePart">
                                <cfloop query="rs_department"  >
									<option <cfif rs_teacher.institute_id eq rs_department.institute_id>selected="selected"</cfif> value="<cfoutput>#rs_department.institute_id#</cfoutput>"><cfoutput>#rs_department.institute_name#</cfoutput></option>
								</cfloop>
							</select>
							
							教师类别
							
							<select name="TypeCode" id="TypeCode" class="inlinePart">
                                <cfloop query="rs_type" >
									<option <cfif rs_teacher.tch_type eq rs_type.tch_type>selected="selected"</cfif> value="<cfoutput>#rs_type.tch_type#</cfoutput>"><cfoutput>#rs_type.tch_type_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>

						<div class="label">
							<b>职称</b>
							<select name="TechnicalPositionSeries" id="TechnicalPositionSeries" class="inlinePart"></select>
							<select name="TechnicalPositionID" id="TechnicalPositionID" class="inlinePart"></select>
						</div>--->
                              
                              <hr/>

						<div class="label">
							<b>学历</b>
							<select name="EduCode" id="EduCode">
                                <cfloop query="rs_educational"  >
									<option <cfif rs_teacher.edu_id eq rs_educational.edu_id>selected="selected"</cfif> value="<cfoutput>#rs_educational.edu_id#</cfoutput>"><cfoutput>#rs_educational.edu_background#</cfoutput></option>
								</cfloop>
							</select>
							
						</div>
						
						
						<div class="label">
							<b>电子邮件</b>
							<cfset emailAddress = rs_user.user_email />
							<cfif find( "@email.unknown", emailAddress )>
								<cfset emailAddress = "" />
							</cfif>
							<input name="EmailAddress" id="EmailAddress" type="text" class="typeEnglish" verification="email" maxlength="120" value="<cfoutput>#event.getArg('EmailAddress', emailAddress)#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>联系电话</b>
							<input name="TeacherTelephone" id="TeacherTelephone" type="text" class="typeEnglish" maxlength="16" value="<cfoutput>#event.getArg('TeacherTelephone', rs_teacher.tch_tel)#</cfoutput>" />
						</div>
                              
                               <hr/>
                               <div class="label">
							<b>登录设置</b>
							<input name="role" type="radio" class="typeRadio" value="1" <cfif event.getArg('role', rs_user.role) eq "1">checked="checked"</cfif> />正常登录
							<input name="role" type="radio" class="typeRadio" value="0" <cfif event.getArg('role', rs_user.role) eq "0" >checked="checked"</cfif> />限制登录
						</div>
                              
                              <div class="label">
							<b>登录名</b>
							<input name="userLogin" id="userLogin" type="text" class="typeEnglish" maxlength="16" value="<cfoutput>#event.getArg('userLogin', rs_user.user_login)#</cfoutput>" />
						</div>
                              
						<div class="label">
                              <p class="notice">如果不修改密码，请留空</p>
							<b>用户密码</b>
							<input name="password" id="password" type="password"  verification="password" class="typeEnglish" maxlength="16" value="" />
						</div>
                              <div class="label">
							<b>密码确认</b>
							<input name="password2" id="password2" type="password"  verification="password" class="typeEnglish" maxlength="16" value="" />
						</div>
						
						<div class="lable">
							<input class="button" type="submit" value="更新" />
						</div>
						
					</form>
					
					<cfset i = 0 />
					<cfset targetSeries = left(rs_teacher.tp_id,2) />
					<cfset targetPosition = rs_teacher.tp_id />
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						
						$(document).ready(function() {
						
							var technicalPositionArray = [
															<cfloop query = "rs_technicalPosition">
																<cfset i++ />
																<cfset id = rs_technicalPosition.tp_id />
																<cfset pid = "" />
																<cfif right(id, 1) eq "0">
																	<cfset id = left(id, 2) />
																	<cfelse>
																	<cfset pid = left(id, 2) />
																</cfif>
																['<cfoutput>#id#</cfoutput>','<cfoutput>#rs_technicalPosition.tp_series#</cfoutput>','<cfoutput>#pid#</cfoutput>']<cfif i lt rs_technicalPosition.recordCount>,</cfif>
															</cfloop>
															];
							
							function inputFlush(inputID, dataArray, parentID, preValue) {
								
								$("#" + inputID).removeOption(/./);
									for (var i = 0; i < dataArray.length; i++) {
										if (dataArray[i][2] == parentID) {
											$("#" + inputID).addOption(dataArray[i][0], dataArray[i][1]);
										}
									}
										
									if (preValue) {
										$("#" + inputID).val(preValue);
									}
									else {
										$("#" + inputID).val($("#" + inputID + " option:first").attr('value'));
									}
							}
							
							/* Preset value */
							inputFlush("TechnicalPositionSeries", technicalPositionArray, "", '<cfoutput>#event.getArg("TechnicalPositionSeries", targetSeries)#</cfoutput>');
							inputFlush("TechnicalPositionID", technicalPositionArray, $("#TechnicalPositionSeries").val(), '<cfoutput>#event.getArg("TechnicalPositionID", targetPosition)#</cfoutput>');	
							
							$("#TechnicalPositionSeries").change(function(){
								inputFlush("TechnicalPositionID", technicalPositionArray, $(this).val());
							});
							
						});
						// -->
						//]]>
					</script>
					
					
					
					
				</div>
                    
                    
                     <div id="Picture" class="tabContent">
					<div class="noticeBlock">
						<h3>电子照片</h3>
						<hr/>
					</div>
					
					<div class="mbl">
						<img class="img_border" width="240" height="320" src="teacher/print/<cfoutput>#rs_teacher.tch_id#</cfoutput>.jpg" />
					</div>

					<form target="output" id="formPic" onSubmit="javascript:return processVerfiyForm('formPic');" class="formWrapper" method="post" enctype="multipart/form-data" action="<cfoutput>#buildURL('uploadTeacherPicDo')#</cfoutput>">
						<input type="hidden" name="teacherId" value="<cfoutput>#tchId#</cfoutput>" />
						
						<div class="label">
							<span class="req">*</span><b>更新照片</b>
							<input name="upload" id="upload" type="file" verification="required" />
							<p class="notice">请使用至少 480x640 尺寸（比例4:3）的 jpg 图片作为上传文件</p>
						</div>
						
						<div class="lable"><input id="importTrigger" class="button" type="submit" value="更新照片" /></div>
						
					</form>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$(document).ready(function() {
							$("#importTrigger").click(function(){
								
								if ( processVerfiyForm('formPic') ) {
									$("#output").attr("src","about:blank").removeClass("hidden_elem");
								}
								
							});
						});
						// -->
						//]]>
					</script>
					
					
					<iframe name="output" id="output" class="UIframeBox hidden_elem" src="about:blank" frameborder="0"></iframe>

				</div>
				
			</div>
		</li>
	</ul>
</div>
